import Vue from 'vue'
import App from './App'

import pageHead from './components/page-head.vue'
import pageFoot from './components/page-foot.vue'
import uLink from '@/components/uLink.vue'
import store from './store'

Vue.config.productionTip = false

Vue.prototype.$enviorment = 'https://api.xiaoxingauto.com'; 
Vue.prototype.$domain = Vue.prototype.$enviorment + '/zfb/api/'

Vue.prototype.$get = function(url,data,callback){
	uni.request({
		header: { 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' },
		url: this.$domain + url,
		dataType: 'json', //默认 json格式
		method: 'GET', //请求方式
		data:data,
		success: (res) => {
			callback(res)
			// console.log(res.data);
		},
		fail: (error) => {
			console.log(error)
		}
	})
}

Vue.prototype.$post = function(url,data,callback){
	uni.request({
		url: this.$domain + url,
		dataType: 'json', //默认 json格式
		method: 'POST', //请求方式
		data:data,
		success: (res) => {
			callback(res)
			// console.log(res.data);
		},
		fail: (error) => {
			console.log(error)
		}
	})
}

Vue.prototype.$store = store
Vue.prototype.$backgroundAudioData = {
	playing: false,
	playTime: 0,
	formatedPlayTime: '00:00:00'
}

Vue.component('page-head', pageHead)
Vue.component('page-foot', pageFoot)
Vue.component('uLink', uLink)

App.mpType = 'app'

const app = new Vue({
	store,
	...App
})
app.$mount()
